<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>性格考评</title>
    <link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css">
</head>
<style>
    .table-responsive {
        max-width: 800px;
        margin: 0 auto;
    }
</style>
<body>
<div class="table-responsive">
    <form action="examSubmit" method="post">
        <table class="table table-hover">
            <tr>
                <th>#</th>
                <th>问题</th>
                <th>选项</th>
            </tr>
            <#list questions as q>
                <tr>
                <td>${q_index+1}</td>
                <td><label for="q${q_index}">${q.que}</label></td>
                <td>
            <select class="form-control _select" name="answer[${q_index}]" id="q${q_index}" >
            <#--${q.ansSelect}-->
                <option value="0" selected="selected">-</option>
                <#list q.ansSelect as ans>
                    <option value='${ans.value}'>${ans.key}</option>
                </#list>
                </select>
                </td>
                </tr>
            </#list>
        </table>
        <div class="form-group">
            <label for="InputName">姓名：</label>
            <input name="name" class="form-control" id="InputName"/>
        </div>
    </form>
    <button id="submit" class="btn btn-primary btn-lg btn-block">提交</button>
</div>
<div style="height: 50px;"></div>
<script src="/js/jquery.js"></script>
<script src="/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript">
    $(function () {
        $("#submit").click(function () {
            var check = true;
            var name = $("#InputName").val();
            if (name == "") {
                alert("记得填写姓名哦！");
                $("#InputName").focus();
                check=false;
                return false;
            }
            $("._select").each(function () {
                if ($(this).val() == "0") {
                    alert("还有题目未选择");
                    $(this).focus();
                    check=false;
                    return false;
                }
            })
            if (check){
                $("form").submit();
            }
        })
    })
</script>
</body>
</html>
